#!/usr/bin/env python
import sys, re
from model import *
from querymanager import *
    
if __name__ == "__main__":
    arg = sys.argv[1:]
    if len(arg) != 2:
        print '''Usage: query <dictionary.txt> <postings.txt>\n       Terminate with Ctrl+d'''
    try:
        import psyco
        psyco.full()
    except:
        pass
    index = Index.fromFile(arg[0],arg[1])
    qm = QueryManager(index)
    
    line = sys.stdin.readline()
    while line:
        qm.handle(line)
        line = sys.stdin.readline()
        